<!--
 * @Author: your name
 * @Date: 2021-02-23 10:39:10
 * @LastEditTime: 2021-02-23 11:02:56
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \mypro\table.html
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            font-family: '楷体';
        }

        
        main{
            width: 600px;
            height: 400px;
            background-color: #f9f1db;
            margin: 100px auto;
        }
        ul{
            width: 100%;
        }
        li {
            list-style-type: none;
            float: left;
            width: 25%;
            height: 50px;
            text-align: center;
            line-height: 50px;
            background-color: skyblue;
            color: #f9f1db;
            cursor: pointer;
            font-size: 20px;
        }
        div{
            width: 100%;
            height: 350px;
            background-color: skyblue;
            float: left;
            font-size: 40px;
            line-height: 350px;
            text-align: center;
            color: #f9f1db;
            display: none;
        }
        .active{
            color: skyblue;
            background-color: #f9f1db;
        }
        .con{
            color: skyblue;
            background-color: #f9f1db;
            display: block;
        }
    </style>
</head>

<body>
    <main>
        <ul>
            <li class="active">腾讯</li>
            <li>阿里</li>
            <li>百度</li>
            <li>新浪</li>
        </ul>
        <div class="con">腾讯</div>
        <div>阿里</div>
        <div>百度</div>
        <div>新浪</div>
    </main>
</body>
<script>
    const lis = document.querySelectorAll('li');
    const vs = document.querySelectorAll('div');
    //console.log(lis,vs)
    for(let i=0; i<lis.length; i++){
        lis[i].onclick = () => {
            for(let j=0; j<vs.length; j++){
                lis[j].classList.remove('active');
                vs[j].classList.remove('con');
            }
            lis[i].classList.add('active');
            vs[i].classList.add('con');
        }
    }
</script>
</html>